#ifndef PROCESS_FILTER_AGENT_H
#define PROCESS_FILTER_AGENT_H

#include <atomic>
#include <memory>
#include <vector>
#include "config.h"
#include "filter.h"
#include "ioctl_channel.h"
#include "thread_pool.h"

class FilterService {
public:
    FilterService() = default;

    ~FilterService();

    bool Init(FilterConfig &config);

    void AddFilter(const std::shared_ptr<Filter> &filter);

    void SetChannel(const std::shared_ptr<IoctlChannel> &c);

    bool Start();

    void Stop();

private:
    bool Accept(const ProcessInfo &process) const;

    void Dispatch(IO_MSG &msg);

    void OnMessage(IO_MSG &msg);

    void Update();

    std::vector<std::shared_ptr<Filter>> filters;
    std::shared_ptr<IoctlChannel> channel;
    COMMON::ThreadPool threadPool{16};  // 16: thread pool size
    std::atomic<bool> isRunning{false};
};

#endif
